package data_structure;

public class leetcode_0121 {
    public int maxProfit(int[] prices) {
        int max=0;
        int len=prices.length;
        int []list=new int[len];
        list[0]=prices[0];
        for(int i=1;i<len;++i){
            list[i]=(prices[i]>list[i-1])?list[i-1]:prices[i];
            max=(max>prices[i]-list[i-1])?max:prices[i]-list[i-1];
        }
        return max;
    }
}
